﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web;

namespace BSCMFF.Core
{
    /// <summary>
    /// Page with ability to change its language.
    /// </summary>
    /// <remarks>All used pages inherit from it.</remarks>
    public partial class MultiLanguagePage : Page
    {
        /// <summary>
        /// Default american english language.
        /// </summary>
        private const string m_DefaultCulture = "en-US";

        /// <summary>
        /// Sets the <see cref="P:System.Web.UI.Page.Culture"/> and <see cref="P:System.Web.UI.Page.UICulture"/> for the current thread of the page.
        /// </summary>
        /// <remarks></remarks>
        protected override void InitializeCulture()
        {
            
            String selectedLanguage;

            HttpCookie cookie = Request.Cookies["Culture"];
            if (cookie != null)
            {
                selectedLanguage = cookie.Value;
            }
            else
            {
                selectedLanguage = m_DefaultCulture;
            }

            UICulture = selectedLanguage;
            Culture = selectedLanguage;

            base.InitializeCulture();
        }
        
    }
}
